package com.litchishell.easy;

/**
 * @author LitchiShell
 * @description: 题目70：爬楼梯
 * @create 2022-08-30
 */
public class Solution015 {

    public int climbStairs(int n) {
        if(n == 1) {
            return 1;
        }
        if(n == 2) {
            return 2;
        }
        // 递归复杂度较大
        int temp = 0;
        int left = 1;
        int right = 2;
        for(int i=3; i<=n; i++) {
            temp = right;
            right = left + right;
            left = temp;
        }
        return right;
    }
}
